$(function() {
	
	var data = [
		
		{
			city: '北京',
			carStyle: '经济型',
			startingFee: '0',
			longTimeCost: '0.25',
			mileage: '1.6',
			mileageSettlement: '0.1',
			miniConsumption: '6',
			longFee: '0.5',
			nightCost: '0.2',
			nightTimePeriod: '23:00-5:00',
			status: 1
		},
		{
			city: '北京',
			carStyle: '经济型',
			startingFee: '0',
			longTimeCost: '0.25',
			mileage: '1.6',
			mileageSettlement: '0.1',
			miniConsumption: '6',
			longFee: '0.5',
			nightCost: '0.2',
			nightTimePeriod: '23:00-5:00',
			status: 1
		}
		
	];
	
	var table = $("#table").DataTable({
		data: data,
		columnDefs: [
			{
				targets: -1,
				data: null,
				defaultContent: "<button class='btn btn-edit'>编辑</button>"+
								"<button class='btn btn-enable'>启用</button>"
			},
			{targets: 0,data: 'city'},
			{targets: 1,data: 'carStyle'},
			{targets: 2,data: 'startingFee'},
			{targets: 3,data: 'longTimeCost'},
			{targets: 4,data: 'mileage'},
			{targets: 5,data: 'mileageSettlement'},
			{targets: 6,data: 'miniConsumption'},
			{targets: 7,data: 'longFee'},
			{targets: 8,data: 'nightCost'},
			{targets: 9,data: 'nightTimePeriod'},
			{targets: 10,data: 'status',render: function(data, type, row) {
				if(data == 1) {return "启用";}
			}}
		]
	});
	
	//点击添加按钮，弹出添加计价规则模态框
	$(".btn-add").on("click", function() {
		
		$("#myModalAdd").modal('show');
		
	});
	
	
	//点击编辑按钮，弹出编辑计价规则模态框
	$('#table tbody').on( 'click', '.btn-edit', function () {
		
		$("#myModalEdit").modal('show');
		
	});
	
});
